using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace BMC.ARSystem
{
	[ARStructTypeInfo(Name = "ARPushFieldsActionStruct", NumberOfMembers = 3u), ClassInterface, Guid("2ecd7391-b9c8-4fb5-a16b-5fb08d679cf8"), ProgId("BMC.ARSystem.PushFieldsAction")]
	public class PushFieldsAction : Action
	{
		[ARStructMemTypeInfo(Name = "pushFieldsList", Offset = 0u)]
		private ArrayList _fieldAssignments;
		[ARStructMemTypeInfo(Name = "sampleServer", Offset = 1u)]
		private string _sampleServer;
		[ARStructMemTypeInfo(Name = "sampleForm", Offset = 2u)]
		private string _sampleForm;
		private string _toServer;
		private string _toForm;
		private string _pushIfQual;
		private uint _noMatchOption;
		private uint _multiMatchOption;
		private bool _byLikeIds;
		private bool _isSetToDefaults;
		public string SampleServer
		{
			get
			{
				return this._sampleServer;
			}
			set
			{
				this._sampleServer = value;
			}
		}
		public string SampleForm
		{
			get
			{
				return this._sampleForm;
			}
			set
			{
				this._sampleForm = value;
			}
		}
		public ArrayList FieldAssignments
		{
			get
			{
				return this._fieldAssignments;
			}
			set
			{
				this._fieldAssignments = value;
			}
		}
		public string PushToServer
		{
			get
			{
				return this._toServer;
			}
			set
			{
				this._toServer = value;
			}
		}
		public string PushToForm
		{
			get
			{
				return this._toForm;
			}
			set
			{
				this._toForm = value;
			}
		}
		public string PushIfQualification
		{
			get
			{
				return this._pushIfQual;
			}
			set
			{
				this._pushIfQual = value;
			}
		}
		public uint NoMatchOption
		{
			get
			{
				return this._noMatchOption;
			}
			set
			{
				this._noMatchOption = value;
			}
		}
		public uint MultiMatchOption
		{
			get
			{
				return this._multiMatchOption;
			}
			set
			{
				this._multiMatchOption = value;
			}
		}
		public bool IsAssignmentsByMatchingIds
		{
			get
			{
				return this._byLikeIds;
			}
			set
			{
				if (this._byLikeIds == value)
				{
					return;
				}
				this.FieldAssignments = new ArrayList();
				this._byLikeIds = value;
			}
		}
		public bool IsAssignmentSetToDefaults
		{
			get
			{
				return this._isSetToDefaults;
			}
			set
			{
				if (this._isSetToDefaults == value)
				{
					return;
				}
				this.FieldAssignments = new ArrayList();
				this._isSetToDefaults = value;
			}
		}
		public PushFieldsAction()
		{
		}
		internal PushFieldsAction(object[] rawData, Server server)
		{
			this.SampleServer = (string)Util.GetAt(rawData, new int[]
			{
				1
			});
			this.SampleForm = (string)Util.GetAt(rawData, new int[]
			{
				2
			});
			int[] array = new int[3];
			object[] array2 = (object[])Util.GetAt(rawData, array);
			this.PushToServer = (string)array2[0];
			if (this.PushToServer.StartsWith("$") && this.PushToServer.EndsWith("$"))
			{
				server = server.Session.GetServer(this.SampleServer);
			}
			else
			{
				if (this.PushToServer != "*" && this.PushToServer != "@" && this.PushToServer != server.ServerName)
				{
					server = server.Session.GetServer(this.PushToServer);
				}
			}
			server.Session.CurrentRemoteForm = (this.PushToForm = (string)array2[1]);
			if (server.Session.CurrentRemoteForm.StartsWith("$") && server.Session.CurrentRemoteForm.EndsWith("$"))
			{
				server.Session.CurrentRemoteForm = this.SampleForm;
			}
			if (server.Session.CurrentRemoteForm != null && (server.Session.CurrentRemoteForm.Equals("@") || server.Session.CurrentRemoteForm.Equals("*") || server.Session.CurrentRemoteForm.Equals("CURRENT SCREEN") || server.Session.CurrentRemoteForm.Equals("CURRENT TRANSACTION")))
			{
				server.Session.CurrentRemoteForm = server.Session.CurrentLocalForm;
			}
			this.PushIfQualification = server.FormatQualification(server.Session.CurrentRemoteForm, Util.GetAt(array2, new int[]
			{
				2
			}));
			this.NoMatchOption = (uint)array2[5];
			this.MultiMatchOption = (uint)array2[6];
			ArrayList arrayList = new ArrayList();
			array = new int[1];
			object[] array3 = (object[])Util.GetAt(rawData, array);
			if (array3 != null && array3.Length > 0)
			{
				object[] array4 = array3;
				for (int i = 0; i < array4.Length; i++)
				{
					object obj = array4[i];
					object arg_25F_0 = (object[])obj;
					array = new int[1];
					object[] rawData2 = (object[])Util.GetAt(arg_25F_0, array);
					object[] assignment = (object[])Util.GetAt((object[])obj, new int[]
					{
						1
					});
					uint num = (uint)Util.GetAt(rawData2, new int[]
					{
						4
					});
					if ((ulong)num == 98uL)
					{
						this.IsAssignmentsByMatchingIds = true;
						break;
					}
					if ((ulong)num == 97uL)
					{
						this.IsAssignmentSetToDefaults = true;
						break;
					}
					server.Session.CurrentFieldId = num;
					object obj2 = "";
					object arg_2FB_0 = (object[])obj;
					array = new int[2];
					array[0] = 1;
					switch ((uint)Util.GetAt(arg_2FB_0, array))
					{
					case 1u:
						obj2 = Util.ConvertFromARValue((object[])Util.GetAt((object[])obj, new int[]
						{
							1,
							1
						}), false, true);
						break;
					case 2u:
					case 4u:
					case 5u:
						obj2 = server.EncodeAssignment(assignment);
						obj2 = server.FormatAssignment(server.Session.CurrentRemoteForm, server.Session.CurrentFieldId, server.Session.CurrentLocalForm, obj2);
						break;
					case 3u:
						obj2 = string.Format("$PROCESS$ {0}", (string)Util.GetAt((object[])obj, new int[]
						{
							1,
							1
						}));
						break;
					case 6u:
					{
						object arg_3B9_0 = (object[])obj;
						array = new int[3];
						array[0] = 1;
						array[1] = 1;
						string text = (string)Util.GetAt(arg_3B9_0, array);
						string text2 = (string)Util.GetAt((object[])obj, new int[]
						{
							1,
							1,
							1
						});
						string text3 = (string)Util.GetAt((object[])obj, new int[]
						{
							1,
							1,
							2
						});
						string text4 = (string)Util.GetAt((object[])obj, new int[]
						{
							1,
							1,
							4
						});
						obj2 = string.Format("$DDE$ {0};{1};{2}{3}{4}", new object[]
						{
							text,
							text2,
							text4,
							(text3.get_Length() > 0) ? ";" : "",
							text3
						});
						break;
					}
					case 7u:
						obj2 = "$" + Util.GetAt(obj, new int[]
						{
							1,
							1,
							2
						}).ToString() + "$";
						break;
					case 8u:
						obj2 = "$" + Util.GetAt(obj, new int[]
						{
							1,
							1,
							2
						}).ToString() + "$";
						break;
					}
					arrayList.Add(new object[]
					{
						num,
						obj2
					});
				}
			}
			this.FieldAssignments = arrayList;
		}
		internal static PushFieldsAction createInstance(object[] rawData, Server server)
		{
			return new PushFieldsAction(rawData, server);
		}
	}
}
